﻿using System;

class LinesNew
{
    static void Main()
    {
        //Telerik Academy Exam 1 @ 7 Dec 2011 Morning

        int num0 = int.Parse(Console.ReadLine());
        int num1 = int.Parse(Console.ReadLine());
        int num2 = int.Parse(Console.ReadLine());
        int num3 = int.Parse(Console.ReadLine());
        int num4 = int.Parse(Console.ReadLine());
        int num5 = int.Parse(Console.ReadLine());
        int num6 = int.Parse(Console.ReadLine());
        int num7 = int.Parse(Console.ReadLine());

        int bestLength = 0;
        int bestCount = 0;

        // Check all horizontal lines
        for (int row = 0; row <= 7; row++)
        {
            int rowBits = 0;
            switch (row)
            {
                case 0:
                    rowBits = num0;
                    break;
                case 1:
                    rowBits = num1;
                    break;
                case 2:
                    rowBits = num2;
                    break;
                case 3:
                    rowBits = num3;
                    break;
                case 4:
                    rowBits = num4;
                    break;
                case 5:
                    rowBits = num5;
                    break;
                case 6:
                    rowBits = num6;
                    break;
                case 7:
                    rowBits = num7;
                    break;
                default:
                    break;
            }

            int length = 0;
            for (int col = 0; col <= 7; col++)
            {
                int cell = (rowBits >> col) & 1;    //търсим 1-ците на всеки ред
                if (cell == 1)
                {
                    length++;
                    if (length > bestLength)
                    {
                        bestLength = length;
                        bestCount = 0;
                    }
                    if (length == bestLength)
                    {
                        bestCount++;
                    }
                }
                else
                {
                    length = 0;
                }
            }
        }

        // Check all vertical lines
        for (int col = 0; col <= 7; col++)
        {
            int length = 0;
            for (int row = 0; row <= 7; row++)
            {
                int rowBits = 0;
                switch (row)
                {
                    case 0:
                        rowBits = num0;
                        break;
                    case 1:
                        rowBits = num1;
                        break;
                    case 2:
                        rowBits = num2;
                        break;
                    case 3:
                        rowBits = num3;
                        break;
                    case 4:
                        rowBits = num4;
                        break;
                    case 5:
                        rowBits = num5;
                        break;
                    case 6:
                        rowBits = num6;
                        break;
                    case 7:
                        rowBits = num7;
                        break;
                    default:
                        break;
                }

                int cell = (rowBits >> col) & 1;    //търсим 1-ците на всеки ред
                if (cell == 1)
                {
                    length++;
                    if (length > bestLength)
                    {
                        bestLength = length;
                        bestCount = 0;
                    }
                    if (length == bestLength)
                    {
                        bestCount++;
                    }
                }
                else
                {
                    length = 0;
                }
            }
        }

        // Check for the special case when the largest cell has size 1x1
        if (bestLength == 1)
        {
            // Cells with size 1x1 were counted twice --> recalculate them
            bestCount = bestCount / 2;
        }

        Console.WriteLine(bestLength);
        Console.WriteLine(bestCount);

    }
}

